package org.eredlab.g4.demo.web;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.eredlab.g4.ccl.datastructure.Dto;
import org.eredlab.g4.ccl.datastructure.impl.BaseDto;
import org.eredlab.g4.ccl.json.JsonHelper;
import org.eredlab.g4.ccl.util.GlobalConstants;
import org.eredlab.g4.ccl.util.G4Utils;
import org.eredlab.g4.demo.core.ReportHelper;
import org.eredlab.g4.demo.service.DemoService;
import org.eredlab.g4.rif.report.excel.ExcelExporter;
import org.eredlab.g4.rif.report.word.WordExporter;
import org.eredlab.g4.rif.web.BaseAction;
import org.eredlab.g4.rif.web.CommonActionForm;

/**
 * 演示用 Action
 * 
 * @author YY
 * @since 2011年2月1日
 * @see BaseAction
 */

/**
 * @author Administrator
 *
 */
public class PurchasingManageAction extends BaseAction{
	
	private DemoService demoService = (DemoService) getService("demoService");
	
	
	/**
	 * 采购方式页面管理
	 * 
	 * @param
	 * @return
	 */
	public ActionForward purchasingMannerManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("purchasingMannerManager");
	}
	
	/**
	 * 插入采购方式
	 * @param
	 * @return
	 */
	public ActionForward insertPurchasingManner(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.insertPurchasingManner(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "采购信息添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
	
	
	/**
	 * 查询采购方式
	 * @param
	 * @return
	 */
	public ActionForward selectPurchasingManners(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectPurchasingManners", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectPurchasingManners", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 查询采购方式
	 * @param
	 * @return
	 */
	public ActionForward selectSimplePurchasingManners(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);
		List areaList = g4Reader.queryForList("selectSimplePurchasingManners", dto);
		String jsonString = JsonHelper.encodeObject2Json(areaList);
		super.write(jsonString, response);
		return mapping.findForward(null);	
	}
	
	
	/**
	 * 修改采购方式
	 * @param
	 * @return
	 */
	public ActionForward updatePurchasingManner(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.updatePurchasingManner(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除采购方式
	 * @param
	 * @return
	 */
	public ActionForward deletePurchasingManner(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deletePurchasingManner(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "采购方式删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 采购项目页面初始化
	 * 
	 * @param
	 * @return
	 */
	public ActionForward purchasingmanageInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("projectManager");
	}
		
	/**
	 * 插入采购项目
	 * @param
	 * @return
	 */
	public ActionForward insertProject(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.insertProject(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "采购信息添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
		
	/**
	 * 查询采购项目
	 * @param
	 * @return
	 */
	public ActionForward selectProjects(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectProjects", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectProjects", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 修改采购项目
	 * @param
	 * @return
	 */
	public ActionForward updateProject(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.updateProject(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除采购项目
	 * @param
	 * @return
	 */
	public ActionForward deleteProject(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deleteProject(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "采购方式删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 采购单位初始化
	 * @param
	 * @return
	 */
	public ActionForward purchasingcompanysManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("purchasingcompanysManager");
	}
	
	/**
	 * 插入采购单位
	 * @param
	 * @return
	 */
	public ActionForward insertPurchasingcompany(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {		
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.insertPurchasingcompany(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "采购信息添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
		
	
	/**
	 * 查询采购单位
	 * @param
	 * @return
	 */
	public ActionForward selectPurchasingcompanys(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectPurchasingcompanys", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectPurchasingcompanys", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);		
	}
	
	
	/**
	 * 查询采购单位
	 * @param
	 * @return
	 */
	public ActionForward selectSimplePurchasingcompanys(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);
		List areaList = g4Reader.queryForList("selectSimplePurchasingcompanys", dto);
		String jsonString = JsonHelper.encodeObject2Json(areaList);
		super.write(jsonString, response);
		return mapping.findForward(null);	
	}
	
	
	/**
	 * 修改采购单位
	 * @param
	 * @return
	 */
	public ActionForward updatePurchasingcompany(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.updatePurchasingcompany(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除采购单位
	 * @param
	 * @return
	 */
	public ActionForward deletePurchasingcompany(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deletePurchasingcompany(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "采购方式删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	
	/**
	 * 供应商初始化
	 * @param
	 * @return
	 */
	public ActionForward supplycompanyManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("supplycompanyManager");
	}
	
	/**
	 * 插入供应商
	 * @param
	 * @return
	 */
	public ActionForward insertSupplycompanyManager(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {		
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.insertSupplycompany(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "采购信息添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 查询供应商
	 * @param
	 * @return
	 */
	public ActionForward selectSupplycompanys(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectSupplycompanys", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectSupplycompanys", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 查询供应商
	 * @param
	 * @return
	 */
	public ActionForward selectSimpleSupplycompanys(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);
		List areaList = g4Reader.queryForList("selectSimpleSupplycompanys", dto);
		String jsonString = JsonHelper.encodeObject2Json(areaList);
		super.write(jsonString, response);
		return mapping.findForward(null);	
	}
	
	/**
	 * 修改供应商
	 * @param
	 * @return
	 */
	public ActionForward updateSupplycompany(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.updateSupplycompany(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除供应商
	 * @param
	 * @return
	 */
	public ActionForward deleteSupplycompany(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deleteSupplycompany(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "供应商删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	
	/**
	 * 产品初始化
	 * @param
	 * @return
	 */
	public ActionForward productManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("productManager");
	}
	
	/**
	 * 产品类别初始化
	 * @param
	 * @return
	 */
	public ActionForward productTypeManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("productTypeManager");
	}
	
	
	/**
	 * 插入产品（类别）
	 * @param
	 * @return
	 */
	public ActionForward insertProduct(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {		
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);		
		String prd_parentcode = inDto.getAsString("prd_parentcode");
		if(prd_parentcode == null)
			prd_parentcode = "";
		String prd_code;
		for(int i = 1;i<100;i++)
		{
			if(i<10)
				prd_code = prd_parentcode + "0" + i;
			else
				prd_code = prd_parentcode + i;
			inDto.put("prd_code", prd_code);
			try
			{
				demoService.insertProduct(inDto);
				break;
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}								
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "产品添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 查询产品（类别），只查两个字段用来绑定下拉菜单
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 产品集
	 * @throws Exception
	 */
	public ActionForward selectSimpleProducts(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);
		List areaList = g4Reader.queryForList("selectSimpleProducts", dto);
		String jsonString = JsonHelper.encodeObject2Json(areaList);
		super.write(jsonString, response);
		return mapping.findForward(null);
	}
	
	
	/**
	 * 查询产品（类别）
	 * @param
	 * @return
	 */
	public ActionForward selectProducts(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectProducts", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectProducts", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 修改产品（类别）
	 * @param
	 * @return
	 */
	public ActionForward updateProduct(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);		
		String prd_parentcode = inDto.getAsString("prd_parentcode");
		if(prd_parentcode == null)
			prd_parentcode = "";
		String prd_code;
		for(int i = 1;i<100;i++)
		{
			if(i<10)
				prd_code = prd_parentcode + "0" + i;
			else
				prd_code = prd_parentcode + i;
			inDto.put("prd_code", prd_code);
			try
			{
				demoService.updateProduct(inDto);
				break;
			}
			catch(Exception e)
			{
			}
		}	
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "产品修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除产品（类别）
	 * @param
	 * @return
	 */
	public ActionForward deleteProduct(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deleteProduct(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "此条数据已删除!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}		
	
	/**
	 * 产品品牌初始化
	 * @param
	 * @return
	 */
	public ActionForward brandManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("brandManager");
	}
	
	/**
	 * 插入产品品牌
	 * @param
	 * @return
	 */
	public ActionForward insertBrand(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {		
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.insertBrand(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "产品品牌添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
	
	
	/**
	 * 查询产品品牌，只查两个字段用来绑定下拉菜单
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 品牌集
	 * @throws Exception
	 */
	public ActionForward selectSimpleBrands(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);
		List areaList = g4Reader.queryForList("selectSimpleBrands", dto);
		String jsonString = JsonHelper.encodeObject2Json(areaList);
		super.write(jsonString, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 查询产品品牌
	 * @param
	 * @return
	 */
	public ActionForward selectBrands(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectBrands", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectBrands", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);		
	}
	
	
	/**
	 * 修改产品品牌
	 * @param
	 * @return
	 */
	public ActionForward updateBrand(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.updateBrand(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除产品品牌
	 * @param
	 * @return
	 */
	public ActionForward deleteBrand(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deleteBrand(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "产品品牌删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	
	/**
	 * 产品型号初始化
	 * @param
	 * @return
	 */
	public ActionForward productmodelManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("productmodelManager");
	}
	
	/**
	 * 插入产品型号
	 * @param
	 * @return
	 */
	public ActionForward insertProductmodel(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {		
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.insertProductmodel(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "产品品牌添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
	
	
	/**
	 * 查询产品型号，只查两个字段用来绑定下拉列表
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward selectSimpleProductmodels(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);
		List areaList = g4Reader.queryForList("selectSimpleProductmodels", dto);
		String jsonString = JsonHelper.encodeObject2Json(areaList);
		super.write(jsonString, response);
		return mapping.findForward(null);
	}		
	
	/**
	 * 查询产品型号
	 * @param
	 * @return
	 */
	public ActionForward selectProductmodels(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectProductmodels", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectProductmodels", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);		
	}
	
	
	/**
	 * 修改产品型号
	 * @param
	 * @return
	 */
	public ActionForward updateProductmodel(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.updateProductmodel(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除产品型号
	 * @param
	 * @return
	 */
	public ActionForward deleteProductmodel(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deleteProductmodel(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "产品型号删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	
	/**
	 * 采购统计初始化
	 * @param
	 * @return
	 */
	public ActionForward purchasingsStatisticsInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("purchasingsStatistics");
	}
	
		
	/**
	 * 采购管理页面初始化
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward purchasingManagerInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return mapping.findForward("purchasingManager");
	}
	
	/**
	 * 查询采购合同
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward selectPurchasings(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);		
		List list = g4Reader.queryForPage("selectPurchasings", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectPurchasings", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);	
	}
	
	/**
	 * 查询采购合同，只查名称和id
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward selectSimplePurchasings(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);
		List areaList = g4Reader.queryForList("selectSimplePurchasings", dto);
		String jsonString = JsonHelper.encodeObject2Json(areaList);
		super.write(jsonString, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 插入采购合同
	 * @param
	 * @return
	 */
	public ActionForward insertPurchasing(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);		
		SimpleDateFormat df = new SimpleDateFormat("yy-M-");
		String pur_contractcode;
		for(int i = 1;i<1000;i++)
		{
			pur_contractcode = "" + df.format(new Date()) + i;
			inDto.put("pur_contractcode", pur_contractcode);
			try
			{
				demoService.insertPurchasing(inDto);
				break;
			}
			catch(Exception e)
			{
				e.printStackTrace();
			}
		}								
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "产品添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 修改采购合同
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward updatePurchasing(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		demoService.updatePurchasing(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除采购合同
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward deletePurchasing(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deletePurchasing(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "采购合同删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 采购详细页面初始化
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward purchasingdetailManagerInit(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		return mapping.findForward("purchasingdetailManager");
	}
	
	/**
	 * 插入采购详细信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward insertPurchasingdetail(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		DecimalFormat df  = new DecimalFormat("#.00"); 
		
		Double purdet_budgetfinance = new Double(df.format(inDto.getAsBigDecimal("purdet_budgetfinance")));
		Double purdet_budgetother = new Double(df.format(inDto.getAsBigDecimal("purdet_budgetother")));
		Double purdet_factfinance = new Double(df.format(inDto.getAsBigDecimal("purdet_factfinance")));
		Double purdet_factother = new Double(df.format(inDto.getAsBigDecimal("purdet_factother")));
		
		Double purDet_BudgetTotal = purdet_budgetfinance + purdet_budgetother;
		Double purDet_FactTotal = purdet_factfinance + purdet_factother;
		Double purdet_savingmoney = purDet_BudgetTotal - purDet_FactTotal;
		Double purdet_savingrate = new Double(0);
		try
		{
			 purdet_savingrate = new Double(df.format(purdet_savingmoney / purDet_BudgetTotal * 100));
		}
		catch(Exception e)
		{			
		}		  
		inDto.put("purdet_budgetfinance", purdet_budgetfinance);
		inDto.put("purdet_budgetother", purdet_budgetother);
		inDto.put("purdet_factfinance", purdet_factfinance);
		inDto.put("purdet_factother", purdet_factother);
		inDto.put("purdet_budgettotal",purDet_BudgetTotal);
		inDto.put("purdet_facttotal",purDet_FactTotal);
		inDto.put("purdet_savingmoney", purdet_savingmoney);
		inDto.put("purdet_savingrate", purdet_savingrate);
		inDto.put("purdet_finalprice", purDet_FactTotal);
		
		demoService.insertPurchasingdetail(inDto);
		
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("m", "产品品牌添加成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);		
	}
	
	/**
	 * 查询采购详细信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward selectPurchasingdetails(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto dto = aForm.getParamAsDto(request);	
		super.setSessionAttribute(request, "SELECTPURCHASINGDETAILS_QUERYDTO", dto);
		List list = g4Reader.queryForPage("selectPurchasingdetails", dto);
		Integer countInteger = (Integer) g4Reader.queryForObject("countSelectPurchasingdetails", dto);
		String jsonString = JsonHelper.encodeList2PageJson(list, countInteger, GlobalConstants.FORMAT_Date);
		super.write(jsonString, response);
		return mapping.findForward(null);					
	}
	
	/**
	 * 修改采购详细信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward updatePurchasingdetail(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm cForm = (CommonActionForm) form;
		Dto inDto = cForm.getParamAsDto(request);
		DecimalFormat df  = new DecimalFormat("#.00"); 
		Double purdet_budgetfinance = new Double(df.format(inDto.getAsBigDecimal("purdet_budgetfinance")));
		Double purdet_budgetother = new Double(df.format(inDto.getAsBigDecimal("purdet_budgetother")));
		Double purdet_factfinance = new Double(df.format(inDto.getAsBigDecimal("purdet_factfinance")));
		Double purdet_factother = new Double(df.format(inDto.getAsBigDecimal("purdet_factother")));
		
		Double purDet_BudgetTotal = purdet_budgetfinance + purdet_budgetother;
		Double purDet_FactTotal = purdet_factfinance + purdet_factother;
		Double purdet_savingmoney = purDet_BudgetTotal - purDet_FactTotal;
		Double purdet_savingrate = new Double(df.format(purdet_savingmoney / purDet_BudgetTotal * 100));
		  
		inDto.put("purdet_budgetfinance", purdet_budgetfinance);
		inDto.put("purdet_budgetother", purdet_budgetother);
		inDto.put("purdet_factfinance", purdet_factfinance);
		inDto.put("purdet_factother", purdet_factother);
		inDto.put("purdet_budgettotal",purDet_BudgetTotal);
		inDto.put("purdet_facttotal",purDet_FactTotal);
		inDto.put("purdet_savingmoney", purdet_savingmoney);
		inDto.put("purdet_savingrate", purdet_savingrate);
		inDto.put("purdet_finalprice", purDet_FactTotal);
		
		demoService.updatePurchasingdetail(inDto);
		Dto dto = new BaseDto();
		dto.put("success", new Boolean(true));
		dto.put("msg", "数据修改成功!");
		write(JsonHelper.encodeObject2Json(dto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 删除采购详细信息
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward deletePurchasingdetail(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto outDto = demoService.deletePurchasingdetail(inDto);
		outDto.put("success", new Boolean(true));
		outDto.put("msg", "采购项目删除成功!");
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
	
	/**
	 * 导出采购统计excel
	 * 
	 * @param
	 * @return
	 */
	public ActionForward exportExcelForPurchasingdetails(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Dto parametersDto = new BaseDto();
		parametersDto.put("reportTitle", "阿克苏市财政局采购统计表");
		parametersDto.put("jbr", super.getSessionContainer(request).getUserInfo().getUsername());
		parametersDto.put("jbsj", G4Utils.getCurrentTime());
		Dto inDto = (BaseDto) super.getSessionAttribute(request, "SELECTPURCHASINGDETAILS_QUERYDTO");
		inDto.put("rownum", "500");
		List fieldsList = null;
		fieldsList = g4Reader.queryForList("selectPurchasingdetailsForExcel", inDto);
		parametersDto.put("countXmid", new Integer(fieldsList.size()));// 合计条数
		ExcelExporter excelExporter = new ExcelExporter();
		excelExporter.setTemplatePath("/report/excel/demo/purchasingStatisticsReport.xls");
		excelExporter.setData(parametersDto, fieldsList);
		excelExporter.setFilename("采购统计.xls");
		excelExporter.export(request, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 采购报表页面初始化
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward purchasingReportInit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response)throws Exception {
		return mapping.findForward("purchasingReport");
	}
	
	/**
	 * 生成年份
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward createYears(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response)throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		int currentYear = Calendar.getInstance().get(Calendar.YEAR);
		StringBuilder sb = new StringBuilder("");
		sb.append("[");
		for(int i=0;i<10;i++)
		{
			sb.append("{\"yearname\":\"");
			sb.append(currentYear - i);
			sb.append("\",");
			sb.append("\"yearvalue\":\"");
			sb.append(currentYear - i);
			if(i == 9)
				sb.append("\"}");
			else
				sb.append("\"},");
		}
		sb.append("]");
		
		String jsonString = sb.toString();
		
		System.out.println(jsonString);
		
		super.write(jsonString, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 导出月报表
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward exportExcelForMonthReportForm(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;		
		Dto parametersDto1 = new BaseDto();
		Dto parametersDto2 = new BaseDto();	
		Dto inDto = (BaseDto) super.getSessionAttribute(request, "EXPORTEXCEL_QUERYDTO");
		String year = inDto.getAsString("yearvalue");
		String month = inDto.getAsString("month"); 		
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat typeDf = new SimpleDateFormat("yyyy年M月");
		String startDateString = year + "-" + month + "-01";				
		Date startDate = df.parse(startDateString);
		Calendar cal=Calendar.getInstance(); 
		cal.setTime(startDate);
		cal.add(Calendar.MONTH, 1);
		cal.add(Calendar.DATE, -1);
		Date endDate=cal.getTime();		
		String endDateString = df.format(endDate);		
		inDto.put("pur_purchasingdate_start", startDateString);
		inDto.put("pur_purchasingdate_end", endDateString);
		List[] fieldsLists = new List[11];
		for(int i=0; i<fieldsLists.length;i++)
		{
			fieldsLists[i] = new ArrayList();
		}
		Dto[] parametersDtos = ReportHelper.getReportDtos("月报-" + typeDf.format(startDate),g4Reader,inDto);
		SimpleDateFormat df1 = new SimpleDateFormat("yyyy年M月dd日");
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy年M月");
		Dto parametersDto = new BaseDto();
		parametersDto.put("sjqj","月报-" + df1.format(startDate));
		parametersDto.put("bsrq", df2.format(new Date()));
		ExcelExporter excelExporter = new ExcelExporter();
		excelExporter.setTemplatePath("/report/excel/demo/purchasingsMonthReport.xls");
		//excelExporter.setData(parametersDtos, fieldsLists);
		excelExporter.setData(parametersDto, new ArrayList());
		excelExporter.setFilename("月报表.xls");
		excelExporter.export(request, response);
		//excelExporter.exportMultipleSheet(request, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 导出季度报表
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward exportExcelForQuarterReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;		
		Dto parametersDto1 = new BaseDto();
		Dto parametersDto2 = new BaseDto();	
		Dto inDto = (BaseDto) super.getSessionAttribute(request, "EXPORTEXCEL_QUERYDTO");
		String year = inDto.getAsString("yearvalue");
		int quarter = inDto.getAsInteger("quarter");
		String month = null;
		if(quarter == 1)
			month = "01";
		if(quarter == 2)
			month = "04";
		if(quarter == 3)
			month = "07";
		if(quarter == 4)
			month = "10";
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat typeDf = new SimpleDateFormat("yyyy年");
		String startDateString = year + "-" + month + "-01";		
		Date startDate = df.parse(startDateString);
		Calendar cal=Calendar.getInstance(); 
		cal.setTime(startDate);
		cal.add(Calendar.MONTH, 3);
		cal.add(Calendar.DATE, -1);
		Date endDate=cal.getTime();		
		String endDateString = df.format(endDate);		
		inDto.put("pur_purchasingdate_start", startDateString);
		inDto.put("pur_purchasingdate_end", endDateString);
		List[] fieldsLists = new List[11];
		
		SimpleDateFormat df1 = new SimpleDateFormat("yyyy年M月dd日");
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy年M月");
		Dto parametersDto = new BaseDto();
		parametersDto.put("sjqj","季报-" + df1.format(startDate));
		parametersDto.put("bsrq", df2.format(new Date()));
		
		Dto[] parametersDtos = ReportHelper.getReportDtos("季报-" + typeDf.format(startDate) + "第" + quarter + "季度",g4Reader,inDto);
		
		ExcelExporter excelExporter = new ExcelExporter();	
		excelExporter.setTemplatePath("/report/excel/demo/purchasingsQuarterReport.xls");
		//excelExporter.setData(parametersDtos, fieldsLists);
		excelExporter.setData(parametersDto, new ArrayList());
		excelExporter.setFilename("季度报表.xls");
		//excelExporter.exportMultipleSheet(request, response);
		excelExporter.export(request, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 导出年度报表
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward exportExcelForYearReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;		
		Dto parametersDto1 = new BaseDto();
		Dto parametersDto2 = new BaseDto();	
		Dto inDto = (BaseDto) super.getSessionAttribute(request, "EXPORTEXCEL_QUERYDTO");
		String year = inDto.getAsString("yearvalue");
		String month = "01";
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat typeDf = new SimpleDateFormat("yyyy年");
		String startDateString = year + "-" +month + "-01";		
		Date startDate = df.parse(startDateString);
		Calendar cal=Calendar.getInstance(); 
		cal.setTime(startDate);
		cal.add(Calendar.MONTH, 12);
		cal.add(Calendar.DATE, -1);
		Date endDate=cal.getTime();		
		String endDateString = df.format(endDate);		
		inDto.put("pur_purchasingdate_start", startDateString);
		inDto.put("pur_purchasingdate_end", endDateString);
		List[] fieldsLists = new List[11];
		
		SimpleDateFormat df1 = new SimpleDateFormat("yyyy年M月dd日");
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy年M月");
		Dto parametersDto = new BaseDto();
		parametersDto.put("sjqj","年报-" + df1.format(startDate));
		parametersDto.put("bsrq", df2.format(new Date()));
		
		Dto[] parametersDtos = ReportHelper.getReportDtos("年报-" + typeDf.format(startDate) ,g4Reader,inDto);
		ExcelExporter excelExporter = new ExcelExporter();
		excelExporter.setTemplatePath("/report/excel/demo/purchasingsYearReport.xls");
		//excelExporter.setData(parametersDtos, fieldsLists);	
		excelExporter.setData(parametersDto, new ArrayList());
		excelExporter.setFilename("年度报表.xls");
		//excelExporter.exportMultipleSheet(request, response);
		excelExporter.export(request, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 导出按时间段采购报表
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward exportExcelForReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		Dto parametersDto1 = new BaseDto();
		Dto parametersDto2 = new BaseDto();
		inDto.put("pur_purchasingdate_start", request.getParameter("pur_purchasingdate_start"));
		inDto.put("pur_purchasingdate_end", request.getParameter("pur_purchasingdate_end"));			
		inDto.put("rownuma", "500");
		List fieldsList1 = g4Reader.queryForList("reportForPurchasings", inDto);
		List fieldsList2 = g4Reader.queryForList("reportForPurchasingdetails",inDto);
		List[] fieldsLists = {fieldsList1,fieldsList2};
		Dto[] parametersDtos = {parametersDto1,parametersDto2};
		ExcelExporter excelExporter = new ExcelExporter();
		excelExporter.setTemplatePath("/report/excel/demo/report.xls");
		excelExporter.setData(parametersDtos, fieldsLists);		
		excelExporter.setFilename("按时间统计的采购报表.xls");
		excelExporter.exportMultipleSheet(request, response);
		return mapping.findForward(null);
	}
	
	/**
	 * 导出中标通知单
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward exportWordForOutbidNotice(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = (BaseDto) super.getSessionAttribute(request, "EXPORTEXCEL_QUERYDTO");
		Dto parametersDto1 = new BaseDto();
		Dto parametersDto2 = new BaseDto();	
		inDto.put("rownuma", "500");
		List fieldsList1 = g4Reader.queryForList("reportForPurchasings", inDto);
		List fieldsList2 = g4Reader.queryForList("reportForPurchasingdetails",inDto);				
		WordExporter we = new WordExporter();		
		BaseDto m = (BaseDto)fieldsList1.get(0);		
		String[] po = 
		{
				m.getAsString("pur_invitecode").toString(),
				m.getAsString("pur_contractcodea").toString(),
				m.getAsString("sc_name").toString(),
				m.getAsString("purm_name").toString(),
				m.getAsString("pc_name").toString(),
				m.getAsString("pc_linkman").toString(),
				m.getAsString("pc_telephone").toString(),
				m.getAsString("sc_linkman").toString(),
				m.getAsString("sc_telephone").toString(),
				m.getAsString("purdet_facttotala").toString()
		};		
		we.setParam(po);
		we.setFieldsList(fieldsList2);
		we.export(request, response);
		return mapping.findForward(null);
	}
	
	
	/**
	 * 存取条件session
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward SaveSessionForExport(ActionMapping mapping,ActionForm form,HttpServletRequest request,
			HttpServletResponse response) throws Exception{
		CommonActionForm aForm = (CommonActionForm) form;
		Dto inDto = aForm.getParamAsDto(request);
		super.setSessionAttribute(request, "EXPORTEXCEL_QUERYDTO", inDto);
		Dto outDto = new BaseDto();
		outDto.put("success", new Boolean(true));
		write(JsonHelper.encodeObject2Json(outDto), response);
		return mapping.findForward(null);
	}
}